# _*_ coding:utf-8 _*_

from haystack import indexes
from movie.models import Movie, Review
from django.db.models import Q
import datetime


class MovieIndex(indexes.SearchIndex, indexes.Indexable):
	text = indexes.CharField(document=True, use_template=True)  # document=True haystack搜索引擎将使用此字段的内容作为索引进行检索
	title = indexes.CharField(model_attr='title')  # 创建一个author字段

	def get_model(self):
		return Movie

	def index_queryset(self, using=None):
		return self.get_model().objects.all()


class ReviewIndex(indexes.SearchIndex, indexes.Indexable):
	text = indexes.CharField(document=True, use_template=True)
	title = indexes.CharField(model_attr='title')

	def get_model(self):
		return Review

	def index_queryset(self, using=None):
		return self.get_model().objects.all()